package com.kmzx.one.project.controller;

import com.kmzx.one.common.annotation.ApiAuth;
import com.kmzx.one.project.net.BaseResult;
import com.kmzx.one.project.others.dto.FuncCateInfo;
import com.kmzx.one.project.others.dto.GreatBrand;
import com.kmzx.one.project.others.dto.GreatBrandMain;
import com.kmzx.one.project.service.FuncService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "快美甄选_[ 商品_新品牌_接口 ]")
@RestController
public class FuncController extends BaseController {


    @Autowired
    FuncService funcService;

    @ApiAuth
    @ApiOperation(value = "1.精选品牌", notes = "精选品牌", position = -1)
    @GetMapping(value = "func/home")
    public BaseResult pickedBrand(String userId) {
        try {
            List<GreatBrand> detail = funcService.findGreatBrand(userId);
            BaseResult success = BaseResult.Builder.SUCC().initSuccData(detail);
            return success;
        } catch (Exception e) {
            return handleException(e);
        }
    }

    @ApiOperation(value = "2.品牌区，信息", notes = "品牌区，信息")
    @GetMapping(value = "func/main")
    public BaseResult pickedBrandMain(String funcId, String userId) {
        try {
            GreatBrandMain detail = funcService.findBrandMainInfo(funcId, userId);
            BaseResult success = BaseResult.Builder.SUCC().initSuccData(detail);
            return success;
        } catch (Exception e) {
            return handleException(e);
        }
    }

    @ApiOperation(value = "3.商品分类以及信息", notes = "商品分类以及信息")
    @GetMapping(value = "func/cateAndInfo")
    public BaseResult pickedBrandCate(Integer funcId, String userId) {
        try {
            List<GreatBrand> detail = funcService.findProdOfCateInfo2(userId, funcId);
            BaseResult success = BaseResult.Builder.SUCC().initSuccData(detail);
            return success;
        } catch (Exception e) {
            return handleException(e);
        }
    }


}
